package com.briup.app01.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.briup.app01.bean.CstActivity;
import com.briup.app01.bean.CstActivityExample;
import com.briup.app01.bean.CstActivityExample.Criteria;
import com.briup.app01.dao.CstActivityMapper;
import com.briup.app01.service.CstActivityService;
@Service
public class CstActivityServiceImpl implements CstActivityService {
	@Autowired
	private CstActivityMapper activityMapper;
	public void saveOrUpdate(CstActivity activity) {
		if(activity.getAtvId()==null) {
			activityMapper.insertSelective(activity);
		}else {
			activityMapper.updateByPrimaryKey(activity);
	     }
	}
	public void deleteById(long id) {
		activityMapper.deleteByPrimaryKey(id);
	}
	public CstActivity selectById(long id) {
		return activityMapper.selectByPrimaryKey(id);
	}
	
	public List<CstActivity> select(String cust_name, String place) {
		CstActivityExample example = new CstActivityExample();
    	Criteria criteria = example.createCriteria();
    	if(cust_name!=null) {
    		criteria.andAtvCustNameLike("%"+cust_name+"%");
    	}
    	if(place!=null) {
    		criteria.andAtvPlaceLike("%"+place+"%");
    }
    		return activityMapper.selectByExample(example);
	}
	
	
}